; *****************************************************************
; Virtual manager unit - assebler routines for IA32 arch
; Reindeer OS
;
; Copyrights 2011 Michal Saman, m.saman@designplus.cz.
; This source code is release under the Apache License 2.0.
; http://www.apache.org/licenses/LICENSE-2.0
; *****************************************************************

[GLOBAL clone_page]
clone_page:
	push ebx					; __cdecl - so we must preserve EBX contents
	pushf						; Save EFLAGS
	cli							; disable interrupts
	mov	ebx, [esp+12]			; source address of PAGE
	mov	ecx, [esp+16]			; destination address of PAGE
	mov	edx, cr0
	and	edx, 0x7fffffff
	mov	cr0, edx
	mov edx, 1024

.loop:
	mov eax, [ebx]
	mov	[ecx], eax
	add ebx, 4					; source address + 4
	add ecx, 4					; dest. address + 4
	dec edx						; dec counter
	jnz .loop

	mov edx, cr0
	or  edx, 0x80000000
	mov cr0, edx

	popf						; restore flags (enable interrupts)
	pop ebx						; restore EBX
	ret							; go back
